<%@ page language="java" pageEncoding="utf-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ page import="com.apexedu.framework.util.DBUtil" %>
<%@ page import="com.apexedu.identity.IdConstants" %>
<%@ page import="com.apexedu.identity.entity.LoginUserVO" %>
<%@ page import="com.apexedu.identity.entity.TSysDepart" %>
<%@ page import="com.apexedu.identity.security.CasLoginUtil" %>
<%@ page import="com.apexedu.util.StringUtil" %>
<%@ page import="com.apexedu.portal.constant.Constants" %>
<%
    String basePath = request.getContextPath();
    request.setAttribute("basePath", basePath);

    LoginUserVO tsysUser = (LoginUserVO) session.getAttribute(IdConstants.SESSION_USER);
    TSysDepart tdepart = tsysUser.getDepart();
//    String userDepartname = tdepart.getDepartname();
    String userLoginId = tsysUser.getUserloginid();
    String userName = tsysUser.getUsername();

    //检查系统日志数量，如果太大，提示进行删除
    int bizlog = 0, bizlogAlert = 10000;
    if ("admin".equals(userLoginId)) bizlog = DBUtil.count("from t_sys_biz_log");

    if (StringUtil.isBlank(request.getParameter("flag"))) {
        request.getRequestDispatcher(basePath + "/s/uc/" + Constants.ProjectInfo.PROJECT_CODE + "/i").forward(request, response);
    }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title><s:text name="application_name"/></title>

    <!--框架必需start-->
    <link href="${basePath}/clientui/css/import_basic.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/clientui/skins/default/import_skin.css" rel="stylesheet" type="text/css" id="skin"
          themeColor="blue" prePath="${basePath}/clientui/"/>
    <script type="text/javascript" src="${basePath}/clientui/js/jquery-1.4.js"></script>
    <script type="text/javascript" src="${basePath}/clientui/js/jquery.cookie.js"></script>
    <script type="text/javascript" src="${basePath}/clientui/js/bsFormat.js"></script>
    <!--框架必需end-->

    <!--树组件与弹窗组件  QUI V3.3-->
    <script type="text/javascript" src="${basePath}/component/quidialog/cn.js"></script>
    <script type="text/javascript" src="${basePath}/component/quidialog/drag.js"></script>
    <script type="text/javascript" src="${basePath}/component/quidialog/dialog.js"></script>
    <link href="${basePath}/component/quidialog/blue/style.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/resources/css/base.css" rel="stylesheet" type="text/css"/>
    <!--树组件与弹窗组件 -->

    <!--YS 脚本库start-->
    <script type="text/javascript" src="${basePath}/component/ymprompt/ymPrompt_source.js"></script>
    <link rel="stylesheet" type="text/css" href="${basePath}/component/ymprompt/skin/dmm-green/ymPrompt.css">
    <!--YS 脚本库end-->

    <!--修正IE6支持透明png图片start-->
    <script type="text/javascript" src="${basePath}/clientui/js/method/pngFix/supersleight.js"></script>
    <!--修正IE6支持透明png图片end-->

    <script type="text/javascript">
        if (top.location != self.location) {
            top.location = self.location;
        }
        var basePath = '<%=basePath%>';
        function execLogout() {
            $.get("../identity/ajaxlogin.action?act=logout", {q: (new Date()).getTime()}, function (data) {
                data = eval("(" + data + ")");
                if (data.msg == 'success') {
                    <%
                if( CasLoginUtil.isSsoEnabled() ){
                %>
                    window.location.href = '<%=CasLoginUtil.getCasServerLogoutUrl()%>';
                    <%
                    }else{
                    %>
                    window.location.href = '<%=request.getContextPath() %>?t=' + Math.round(new Date / 1000);
                    <%
                    }
                    %>
                } else {
                    alert(data.msg);
                }
            });
        }
        $(function () {
            var hiconIdx = 0;
            var hiconIndex = jQuery.jCookie('hiconIndex');
            if (hiconIndex != false) {
                hiconIdx = parseInt(hiconIndex);
            }
            $(".nav_icon_h_item >a").filter(':eq(' + hiconIdx + ')').addClass("current");
            $(".nav_icon_h_item >a").each(function (i) {
                $(this).click(function () {
                    $(".nav_icon_h_item >a").removeClass("current");
                    $(this).addClass("current");
                    document.getElementById("frmleft").src = "../identity/leftMenu.action?divIndexNum=" + i;
                    jQuery.jCookie('hiconIndex', i.toString());
                })
            });
            <%if( "admin".equals(userLoginId) && bizlog>bizlogAlert){%>
            top.Dialog.alert("操作日志已达 <%=bizlog%> 条！删除过久的日志记录，可以提升数据库效率。");
            <%}%>

            /**
             * 系统二级菜单点击事件
             */
            $(".supermenuSpan").click(function () {
                $(".menuheader label:contains('" + $(this).html() + "')", $("#frmleft")[0].contentWindow.document).click();
            });
        })

        /**
         * 关闭弹出窗口
         * 子窗口关闭自己：parent.closeEntityWindow()
         */
        var zDiaglog = new top.Dialog();
        var _hasEdit = false;
        function closeEntityWindow() {
            zDiaglog.close();
            if (_hasEdit) {
                //iframe中页面提交过数据，关闭要刷新主页面
                var rightIframe = window.frames['frmright'];
                var cententDataForm = rightIframe.document.forms[0];
                if (cententDataForm) {
                    cententDataForm.action = rightIframe.location.href;
                    cententDataForm.submit();
                } else {
                    rightIframe.location.reload();
                }
            }
        }

        $(function () {
            initStyle();
            $(window).resize(function () {
                initStyle();
            });
        });

        /**
         * 初始化页面样式
         */
        function initStyle() {
            $("#content").height($(window).height() - 45);
            $("#content iframe").height($(window).height() - 90);
        }
    </script>
</head>
<body class="" style="height: 100%;background-color: #f3ede6;">

<div id="floatPanel-1"></div>
<div id="mainFrame" style="height: 100%">
    <!--头部与导航start-->
    <div id="headbox">
        <span id="headtitle"><s:text name="application_name"/></span>
        <span id="exit" onclick='top.Dialog.confirm("确定要退出系统吗",function(){execLogout();});'>退出系统</span>
    </div>
    <div id="content">
        <table>
            <tr class="title">
                <th class="left">欢迎您，<%=userName %>
                </th>
                <th class="center"></th>
                <th id="contentTitle">
                    <span class="homeSpan" onclick="window.location.href='${basePath}/'">首页</span>
                    <label>></label>
                    <span class="supermenuSpan">系统管理</span>
                    <label>></label>
                    <span class="menuSpan">系统变量设置</span>
                </td>
            </tr>
            <tr>
                <td class="left">
                    <IFRAME scrolling="no" width="100%" frameBorder=0 id=frmleft name=frmleft
                            src="../identity/leftMenu.action?divIndexNum=0" allowTransparency="true"></IFRAME>
                </td>
                <td class="center">
                    <img src="${basePath}/resources/images/turnRight.png">
                </td>
                <td>
                    <IFRAME scrolling="no" width="100%" frameBorder=0 id="frmright" name="frmright"
                            src="${basePath}/business/systemList-list.action"
                            allowTransparency="true"></IFRAME>
                </td>
            </tr>
        </table>
    </div>
    <!--浏览器resize事件修正start-->
    <div id="resizeFix"></div>
    <!--浏览器resize事件修正end-->

    <!--载进度条start-->
    <div class="progressBg" id="progress" style="display:none;">
        <div class="progressBar"></div>
    </div>
    <!--载进度条end-->
</body>
</html>
